package com.xujl.fastlib.utils;

import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.CsvFormatStrategy;
import com.orhanobut.logger.DiskLogAdapter;
import com.orhanobut.logger.FormatStrategy;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;

/**
 * @author x
 * @Description
 */
public class LogS {
    private static final String TAG = "::";
    private static final String TIP = "fast>>>";

    public static void init () {
        FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
                .showThreadInfo(true)  // 是否显示线程信息，默认 显示
                .methodCount(0)         // 方法栈打印的个数，默认是 2
                .methodOffset(5)        // 设置调用堆栈的函数偏移值，默认是 5
//                .logStrategy(customLog) // 设置log打印策略，默认是 LogCat
                .tag(TIP)   // 设置全局TAG，默认是 PRETTY_LOGGER
                .build();
        Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
        CsvFormatStrategy formatStrategy2 = CsvFormatStrategy.newBuilder()
                .tag(TIP)
                .build();
        Logger.addLogAdapter(new DiskLogAdapter(formatStrategy2));
    }

    public static void e (String tag, String msg) {
        if (!ConfigManager.getInstance().isDebug()) {
            return;
        }
        Logger.e(tag+TAG+msg);
    }

    public static void w (String tag, String msg) {
        if (!ConfigManager.getInstance().isDebug()) {
            return;
        }
        Logger.w(tag + TAG + msg);
    }

    public static void d (String tag, String msg) {
        if (!ConfigManager.getInstance().isDebug()) {
            return;
        }
        Logger.d(tag+TAG+msg);
    }

    public static void i (String tag, String msg) {
        if (!ConfigManager.getInstance().isDebug()) {
            return;
        }
        Logger.i(tag+TAG+msg);
    }

}
